import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';


import {AppComponent} from './app.component';
import {Product1Component} from './product1/product1.component';
import {ProductService} from './product.service';
import {Product2Component} from './product2/product2.component';
import {LoggerService} from './logger.service';
import {Product2Service} from './product2.service';


@NgModule({
  declarations: [
    AppComponent,
    Product1Component,
    Product2Component
  ],
  imports: [
    BrowserModule
  ],
  providers: [{
    provide: ProductService,
    useFactory: (loggerService, rand) => rand ? new ProductService(loggerService) : new Product2Service(loggerService),
    deps: [LoggerService, 'random']
  }, {
    provide: 'random',
    useValue: Math.random() > 0.5
  }, LoggerService],
  bootstrap: [AppComponent]
})
export class AppModule {
}
